package org.jvnc.rfb.proto.server;

/**
* <br><br><center><table border="1" width="80%"><hr>
* <p>
* Copyright (C) 2006-2007 by Deon Wu
* <p>
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.0
* of the License, or (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU Lesser General Public License</a>
* for more details.
* <p>
* You should have received a copy of the <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">
* GNU Lesser General Public License</a> along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* <hr></table></center>
* **/

import gnu.rfb.PixelFormat;

import java.io.DataInput;
import java.io.IOException;

import org.jvnc.rfb.proto.AbstractDataGram;
import org.jvnc.rfb.proto.Rectangle;

public class FrameBufferUpdate extends AbstractDataGram {
	private byte type = 0;
	private int rectCount = 0;
	private Rectangle[] rects = null;
	
	private PixelFormat pixelFormate = null;
	
	public int getRectCount() {
		return rectCount;
	}

	public void setRectCount(int rectCount) {
		this.rectCount = rectCount;
	}

	public Rectangle[] getRects() {
		return rects;
	}

	public void setRects(Rectangle[] rects) {
		this.rects = rects;
	}

	public byte getType() {
		return type;
	}

	public void setType(byte type) {
		this.type = type;
	}

	public void readData( DataInput input ) throws IOException
	{
		input.readByte();
		rectCount = input.readUnsignedShort();
		log.debug("Updated Rectangle count:" + rectCount);
		rects = new Rectangle[rectCount];
		for(int i = 0; i < rectCount; i++){
			rects[i] = new Rectangle();
			rects[i].setFormat(pixelFormate);
			rects[i].readData(input);
		}
	}

	public PixelFormat getPixelFormate() {
		return pixelFormate;
	}

	public void setPixelFormate(PixelFormat pixelFormate) {
		this.pixelFormate = pixelFormate;
	}
}
